#include "pch.h"

#include<stdlib.h>
#include<iostream>
#include<cstring>
using namespace std;
char *Mystrcat(char* str1, char* str2);
#include <gtest/gtest.h>
char *Mystrcat(char* str1, char* str2)
{
	if (str1 == NULL&&str2 == NULL)
		return NULL;
	if (str1 == NULL&&str2 != NULL)
		return str2;
	if (str2 == NULL&&str1 != NULL)
		return str1;
	int i = 0, j = 0;
	char *ch;
	ch = (char*)malloc(sizeof(char)*strlen(str1) + sizeof(char)*strlen(str2) + sizeof(char));
	while (str1[i] != '\0')
	{
		ch[i] = str1[i];
		i++;
	}
	while (str2[j] != '\0')
	{
		ch[i] = str2[j];
		i++;
		j++;
	}
	ch[i] = '\0';
	return ch;
}
TEST(Mystring, Teststring)
{
	//EXPECT_EQ(strlen("abc") + strlen("def"), strlen("abcdef"));
	EXPECT_STREQ("abcdef", Mystrcat("abc", "def"));
	EXPECT_STREQ("abc", Mystrcat("abc", ""));
	EXPECT_STREQ("abc", Mystrcat("abc", NULL));
	EXPECT_STREQ("abc", Mystrcat(NULL, "abc"));
	EXPECT_STREQ(NULL, Mystrcat(NULL, NULL));
}
int main(int argc, char* argv[])
{
	testing::InitGoogleTest(&argc, argv);
    RUN_ALL_TESTS();
	return 0;
}